﻿using Abp.Dependency;
using Microsoft.AspNetCore.Mvc.Filters;

namespace NetCore.Validation
{
    public class ValidationFilter : IActionFilter, ITransientDependency
    {
        //private readonly IAbpConfiguration _configuration;
        //private readonly IIocResolver _iocResolver;

        //public ValidationFilter(IIocResolver iocResolver, IAbpConfiguration configuration)
        //{
        //    _iocResolver = iocResolver;
        //    _configuration = configuration;
        //}

        public void OnActionExecuted(ActionExecutedContext context)
        {
        }

        public void OnActionExecuting(ActionExecutingContext filterContext)
        {
            ////throw new UserFriendlyException("JN_ValidationFilter Throw");
            //if (!_configuration.IsValidationEnabledForControllers)
            //{
            //    return;
            //}

            //if (filterContext.ActionDescriptor.Id == null)
            //{
            //    return;
            //}
            ////var methodInfo = filterContext.ActionDescriptor.GetMethodInfoOrNull();
            ////if (methodInfo == null)
            ////{
            ////    return;
            ////}

            //using (var validator = _iocResolver.ResolveAsDisposable<AbpActionInvocationValidator>())
            //{
            //    //validator.Object.Initialize(filterContext, methodInfo);
            //    validator.Object.Validate();
            //}
        }
    }
}
